<!-- Modal -->
<div class="modal-dialog wide" style="width: 550px;">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel">
            <#if authData??>
                <#if authData.id??>
                    编辑权限
                <#else>
                    新增权限
                </#if>
            </#if>
            </h4>
        </div>
        <div class="modal-body">
            <div id="errorMessage2"><#include "../../message.ftl" /></div>
            <form class="form-horizontal" role="form" id="authDataForm" method="post"
                  action="${absoluteContextPath}/system/authData/save">
            <#if authData??>
                <#if authData.id??>
                    <input type="hidden" name="id" value="${authData.id}"/>
                <#else>
                    <input type="hidden" name="id" value=""/>
                </#if>
            </#if>
                <div class="row">
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">权限ID<sup style="color: red">*</sup></label>

                        <div class="col-sm-6">
                        <#if authData.id??>
                            <input name="authId" value="${authData.authId!''}" type="text" class="form-control"
                                   readonly="readonly"/>
                        <#else>
                            <input name="authId" value="${authData.authId!''}" type="text" class="form-control"/>
                        </#if>

                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">权限名称<sup style="color: red">*</sup></label>

                        <div class="col-sm-6">
                            <input name="authName" value="${authData.authName!''}" type="text" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group col-md-12">
                        <label class="col-sm-4 control-label">备注</label>

                        <div class="col-sm-6">
                            <textarea name="remark" class="form-control" rows="8">${authData.remark!''}</textarea>
                        </div>
                    </div>
                </div>
                <div style="display: none">
                    <input name="moduleId" type="hidden" value="${moduleId!''}"/>
                </div>
            </form>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</button>
            <button type="button" class="btn btn-primary" onclick="saveAuthData();">保存</button>
        </div>
    </div>
</div>
<script>
    function saveAuthData() {
        $("#" + "authDataForm").ajaxSubmit({
            success: function (data) {
                data = JSON.parse(data);
                if (data.returnCode == 1) {
                    $('#myModal').modal("hide");
                    $.showMessage({parentId: "showMessage2", message: "信息保存成功！", type: "success"});
                    refreshAuth();
                } else {
                    $.showMessage({parentId: "errorMessage2", message: "<strong>错误信息</strong>：" + data.returnMsg, type: "success"});
                }
            }
        });
    }
</script>